package com.spzx.user.api.factory;

import com.spzx.common.core.constant.ServiceNameConstants;
import com.spzx.common.core.domain.R;
import com.spzx.user.api.RemoteUserAddressService;
import com.spzx.user.domain.UserAddress;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;

public class RemoteUserAddressFallbackFactory implements FallbackFactory<RemoteUserAddressService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteUserAddressFallbackFactory.class);

    @Override
    public RemoteUserAddressService create(Throwable cause) {

        log.info("远程调用【"+ ServiceNameConstants.USER_SERVICE+"】服务出问题了");

        return new RemoteUserAddressService() {
            @Override
            public R<UserAddress> getUserAddress(Long id, String source) {
                return R.fail("根据用户地址id获取用户地址对象数据失败了"+cause.getMessage());
            }
        };
    }
}
